public class Solution1323 {
    public int maximum69Number (int num) {
        StringBuilder stringBuilder=new StringBuilder();
        boolean can=true;
        for (char c : String.valueOf(num).toCharArray()) {
            if (c=='6' && can){
                can=false;
                c='9';
            }
            stringBuilder.append(c);
        }
        return Integer.parseInt(stringBuilder.toString());
    }

    public static void main(String[] args) {
        System.out.println(new Solution1323().maximum69Number(9669));
    }
}
